import React,{useState} from 'react'
import { Navigate } from 'react-router-dom'

export default function Home() {
  const [sum,setSum] = useState(1)
  return (
    <div>
      <h2>我是home组件</h2>
      {
        sum===2 ?<Navigate to='/about' replace={true}/> :<h4>当前求和为{sum}</h4>
      }
      <button onClick={()=> {setSum(2)}}>点我将和改为2</button>
    </div>
  )
}
